package com.atguigu.gmall.all.contoller;

import com.atguigu.gmall.item.client.ItemFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.Map;

/**
 * @author: 李旭
 * @create: 2021-07-07 15:45
 **/
@Controller
public class ItemController {

    @Autowired
    private ItemFeignClient itemFeignClient;
    //http://item.gmall.com  /100011742105.html
    @GetMapping("/{skuId}.html")
    public String getItem(@PathVariable Long skuId, Model model){
        //远程Feign调用
        Map map = itemFeignClient.getItem(skuId);//5部分数据
        model.addAllAttributes(map);

        return "item/index";
    }

}
